When using programming languages, it is often desirable that mathematical functions be able to take as one or more of their arguments a second mathematical function. One example is integration, classically denoted:                ∫abƒ(x)dx.In a pseudo code this may also be written equivalently as:        integral (a, b, ƒ)In the pseudo code example, integral is a function that takes as arguments two numbers (a and b) and a function (ƒ). (From elementary integral calculus, we know that integral (a, b, ƒ) may not be defined, but if it is defined, it yields a number.)        
Programming languages that allow functions as arguments to other functions generally allow functions (called “function values”) to be used anywhere that a value can be used—not only as arguments, but also in assignment statements and as components of data structures.
For example, the C programming language has “function pointers” as its function values, and modern LISPs have “closures” as their function values. (A LISP is a LISt Processing language typically used in artificial intelligence applications.) Closures are nested function definitions which can refer to local variables and labels of the function in which they are defined. Unlike the lexical functions provided by some C extensions, closures can be returned from functions and still be called, i.e., they have indefinite extent. A “closure” is a pair consisting of a pointer to a piece of program text (the function pointer) and a lexical context (which specifies the location of names not local to the function and storage locations associated with the names).
The use of functions as arguments to other functions in programming languages goes well beyond the implementation of directly corresponding mathematical functions. For example, graphics systems may associate a function value with each of several possible events. In constructing a window in a windowed environment such as Microsoft® Windows®, a client can specify a mouse-movement function, a separate button-down function for each button, a separate region-entry function for each region, and so on. Uniting the apparently different uses of function values as analogues to mathematical functions and as programmatic devices (as in the graphics example) is the fact that function values permit the writing of more generic functions than would otherwise be possible. Two functions that are similar, but have different sequences of steps in one place, can be captured by a single generic function that takes a function value argument and calls that argument at the place where the two functions had a different sequence of steps. The “different sequence of steps” can be achieved by calling the generic function with different function value arguments.
It is important to distinguish between a function name and an algorithm or rule for performing a computation. “Function” is used herein in the strict mathematical/computer-science sense, i.e., it is an algorithm or rule, not a name. A given function name may be associated with a number of different functions. When a function name appears in a program, the semantics of the programming language must specify how it eventually maps to a particular function. This is often mediated by a type. “Type” is used herein to mean an internal identifier that says how to interpret a value. This definition of “type” embraces both what C and C++ call “type” and also what C++ calls “class,” and thus includes both built-in and user definitions of type and class.
Some programming languages allow a name and type work together to specify a function. For example, the same name may be used both for a function whose argument is a floating-point number and for entirely an different function whose argument is an integer. Having a single name to refer to different functions for different types of arguments is an example of what is called “function overloading,” even though it might more appropriately be called “function name overloading.” We may think of a function name as mapping to a set of functions.
A particular programming language may or may not support function overloading. For example, the C programming language does not support overloading. The type of each variable must be explicitly declared in the source text. Within a given scope (that is, within the set of names that are defined at a particular point in the program), each function name corresponds to at most one function.
Other programming languages, such as the C++ programming language, do support function overloading. Within a given scope, there may be many distinct functions all associated with the same function name. In a language that permits function overloading, the use of a function name in a particular context is potentially ambiguous. To which function does a particular use of a function name refer? Where is the code which implements the particular function? Any language with overloading must be able to resolve these questions. The techniques of resolution for function overloading are called the “overload resolution” rules for the language.
There is an interaction between overload resolution and the type system. In general, the type system is used to resolve the meaning of an overloaded function name, i.e., to choose a particular function from the set of functions to which the name maps. The particulars depend upon the nature of the type system.
Some languages, for example, C++, are “statically typed.” In statically typed languages, the types of expressions are fixed by the text of the program. Thus, the compiler can determine the types of arguments of a given function call in the program text, and use those types to pick which, of all the functions in the set to which the name maps, is the one meant by this particular use of the name.
Other languages, for example, the MATLAB® language, are “dynamically typed.” In these languages, the types of expressions are not fixed by the program text, and as a consequence, overload resolution is dynamic, meaning that the function that is actually called at run-time for a given function application in the source may vary from one evaluation to the next. Dynamic overload resolution relies upon the fact that, in a dynamically typed language, a value directly or indirectly contains type as well as what we will call “content” of some kind. For instance, the content may be a double precision floating point number, which is interpreted in one way, or a string, which is interpreted in another way.
As an example of the behavior that arises in dynamically typed languages, the body of a program loop may contain a function application in which a particular argument has a value that is an integer at one call, and a floating point number at a later call. The compiler is unable to determine at compile time which type the argument may be, and hence is unable to perform overload resolution at compile time. Put differently, it is the run-time machinery that must resolve the overloading, not the compile-time machinery. Although the time is different, types again figure in the resolution—in this case, types of the values of the arguments during runtime, rather than types of the expressions determined at compile time.
The speed of overload resolution in a dynamically typed language can have a significant effect upon the overall speed executing a program. The more efficient the overload resolution is, the faster the program can be run on a given machine, all other factors being held constant.